package com.kalvin.kvf.modules.ks.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kalvin.kvf.common.utils.ShiroKit;
import com.kalvin.kvf.modules.sys.entity.User;
import org.springframework.stereotype.Service;
import com.kalvin.kvf.modules.ks.entity.KSVideo;
import com.kalvin.kvf.modules.ks.mapper.KSVideoMapper;

import java.util.List;

/**
 * <p>
 * 视频库表 服务实现类
 * </p>
 * @since 2023-11-13 16:18:02
 */
@Service
public class KSVideoServiceImpl extends ServiceImpl<KSVideoMapper, KSVideo> implements KSVideoService {

    @Override
    public Page<KSVideo> listVideoPage(KSVideo video) {
        User user = ShiroKit.getUser();
        if(!user.getUsername().equals("admin")){
            video.setPhone(user.getPhone());
        }
        Page<KSVideo> page = new Page<>(video.getCurrent(), video.getSize());
        List<KSVideo> videos = baseMapper.selectVideoList(video, page);
        return page.setRecords(videos);
    }

}
